<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ include file="/taglibs.jsp"%>
<s:url value="/images" var="imgPath"/>
<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick-zh-CN.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/yaodian100.common.js"></script>
<link rel="stylesheet" type="text/css" href="/css/smoothness.datepick.css"/>
<c-rt:set var="midContextPath" value='<%=ServerValue.getMidContextPath()%>'/>
<c-rt:set var="frontContextPath" value='<%=ServerValue.getFrontContextPath()%>'/>
<c-rt:set var="frontHostName" value='<%=ServerValue.getFrontHostname()%>'/>
<script type="text/javascript"> 
	$().ready(function(){
		$('#endDate').datepick({minDate: "+1D", showOn: 'both', 
		   	buttonImageOnly: true, buttonImage: '${imgPath}/calendar.gif',numberOfMonths:2,dateFormat:"yy-mm-dd",yearRange: '-50:+50'});

		$("#submit_button").click(function(){
			if ( validate_data() )
				$("#templateForm").submit();
		});
	});
	function validate_data(){
		if ( $("#endDate").val() == "" ){
			alert("请输入template日期结束时间");
			$("#endDate").focus();
			return false;
		}
		if ( "" == $("#contents").val() ){
			alert("请输入vm内容");
			$("#contents").focus();
			return false;
		}
		return true;
	}
</script>
<h1>渠道Template管理<br/>
<div class="f-link">
	<a href="${midContextPath}/channelTemplate/search.do">回渠道管理列表页</a>
</div>
</h1>
<s:actionerror />
<s:actionmessage />
<s:fielderror />
<br/>
<s:form action="save.do" method="post" id="templateForm">
<table class="tb-data" width="100%">
		<tr>
			<th>*Template类别</th>			
			<td>
				<s:select name="templateType" list="templateTypeMenu.options" listKey="key" listValue="value.name" value="%{template.type}"/>
				<input type="hidden" id="id" name="id" value="${template.id}"/>
			</td>
	  </tr>	
		<tr>
			<th>*渠道</th>			
			<td>        
		    <s:select id="channelName" name="channelName" list="channelNameMenu.options" listKey="key" listValue="value.name" value="%{template.channelName}"/>
       </td>
	  </tr>
	  <tr>
			<th>*template日期结束时间</th>			
			<td>        
		    <input type="text" name="endDate" id="endDate" size="20" value="<fmt:formatDate value="${template.endDate}" pattern="yyyy-MM-dd" />"/>
		    <select id="endTime" name="endTime">
					<c-rt:forEach begin="0" end="23" var="t2" >
						<c-rt:set var="t3">${23-t2}</c-rt:set>	
						<c-rt:if test="${t3<10}">
						<c-rt:set value="0${t3}:59" var="eTime"></c-rt:set>
						</c-rt:if>
						<c-rt:if test="${t3>=10}">
						<c-rt:set value="${t3}:59" var="eTime"></c-rt:set>
						</c-rt:if>
						<option value="${eTime}" <c-rt:if test="${eTime==endTime }">selected</c-rt:if>>${eTime}</option>
					</c-rt:forEach>
				</select>
		  </td>
		</tr>
		<tr>
			<th>*上下架</th>
			<td>
				<s:select name="channelStatus" list="channelStatusMap" listKey="key"  listValue="value" value="%{channelStatus}"/>
			</td>
		</tr>
		<tr>
			<th>vm内容</th>
			<td>
				<s:textarea id="contents" name="contents" cols="80" rows="10"></s:textarea>
			</td>
		</tr>
</table>
*为必填资料
<div class="f-link">
	<a href="#" id="submit_button">存档</a>
</div>
</s:form>